package com.jinke.api.modules.app.response;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.Date;

@Data
@EqualsAndHashCode
@ColumnWidth(value = 32)
public class UmsAdminExport {

    @ExcelProperty(index = 0, value = "id")
    private Integer id;
    @ExcelProperty(index = 1, value = "真实姓名")
    @ColumnWidth(value = 32)
    private String realName;
    @ExcelProperty(index = 2, value = "邮箱")
    @ColumnWidth(value = 32)
    private String email;
    @ExcelProperty(index = 3, value = "销售")
    @ColumnWidth(value = 32)
    private String seller;
    @ExcelProperty(index = 4, value = "用户权限")
    @ColumnWidth(value = 32)
    private String role;
    @ExcelProperty(index = 5, value = "余额")
    @ColumnWidth(value = 32)
    private BigDecimal balance;
    @ExcelProperty(index = 6, value = "保证金")
    @ColumnWidth(value = 32)
    private BigDecimal earnestBalance;
    @ExcelProperty(index = 7, value = "扣除保证金比例")
    @ColumnWidth(value = 32)
    private BigDecimal earnestRate;
    @ExcelProperty(index = 8, value = "押金")
    @ColumnWidth(value = 32)
    private BigDecimal depositBalance;
    @ExcelProperty(index = 9, value = "信用额度")
    @ColumnWidth(value = 32)
    private BigDecimal creditBalance;
    @ExcelProperty(index = 10, value = "当前信用额度")
    @ColumnWidth(value = 32)
    private BigDecimal curCreditBalance;
    @ExcelProperty(index = 11, value = "邀请码")
    @ColumnWidth(value = 32)
    private String invitationCode;
    @ExcelProperty(index = 12, value = "电话")
    @ColumnWidth(value = 32)
    private String phone;
    @ExcelProperty(index = 13, value = "昵称")
    @ColumnWidth(value = 32)
    private String nickName;
    @ExcelProperty(index = 14, value = "备注")
    @ColumnWidth(value = 32)
    private String note;
    @ExcelProperty(index = 15, value = "货运服务")
    @ColumnWidth(value = 32)
    private String channels;
    @ExcelProperty(index = 16, value = "状态")
    @ColumnWidth(value = 32)
    private String status;
    @ExcelProperty(index = 17, value = "公司")
    @ColumnWidth(value = 32)
    private String company;
    @ExcelProperty(index = 18, value = "创建时间")
    @ColumnWidth(value = 32)
    private Date createTime;
    @ExcelProperty(index = 19, value = "登录时间")
    @ColumnWidth(value = 32)
    private Date loginTime;

    public BigDecimal getCurCreditBalance(){
        //余额为负数信用额度要减去透支的
        if(BigDecimal.ZERO.compareTo(balance) >0){
            return creditBalance.add(balance);
        }
        return creditBalance;
    }
}
